package com.example.mobile2121606110syc0409homework;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity1 extends AppCompatActivity {

    private TextView tvMainTitle1;
    private TextView tvMainTit;
    private TextView tvMainTit2;
    private TextView tvMainTit3;
    private TextView tvMainTit4;
    private EditText edtTtPN1;
    private EditText edtTtPN2;
    private Button btnMainjs;
    private TextView tvMainResult;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main1);
        initView();
        btnMainjs.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int a = Integer.parseInt(edtTtPN1.getText().toString());
                int b = Integer.parseInt(edtTtPN2.getText().toString());
                int sum = a+b;
                tvMainResult.setText(String.valueOf(sum));
            }
        });
    }

    private void initView() {
        tvMainTitle1 = (TextView) findViewById(R.id.tvMainTitle1);
        tvMainTit = (TextView) findViewById(R.id.tvMainTit);
        tvMainTit2 = (TextView) findViewById(R.id.tvMainTit2);
        tvMainTit3 = (TextView) findViewById(R.id.tvMainTit3);
        tvMainTit4 = (TextView) findViewById(R.id.tvMainTit4);
        edtTtPN1 = (EditText) findViewById(R.id.edtTtPN1);
        edtTtPN2 = (EditText) findViewById(R.id.edtTtPN2);
        btnMainjs = (Button) findViewById(R.id.btnMainjs);
        tvMainResult = (TextView) findViewById(R.id.tvMainResult);
    }
}